package net.yla.smartbus.core.util;

import net.yla.smartbus.core.exception.AppException;

/**
 * @Author : GaoMing
 * @Create_Date : 2019/12/11/13:59
 * @Pack_name : net.seocoo.smartbus.core.util : DirectionUtil
 * *****************************************************
 * 注释: 方向工具类 根据方向角度判断方向
 */
public class DirectionUtil {

    public static String direction(int angle){

        if ( angle <= 0 && 360 <= angle ) {
            throw new AppException("方位不对", 705);
        }

        String direction = null;

        if (angle == 0) {
            direction = "正北";
        }
        if (angle == 90) {
            direction = "正东";
        }
        if (angle == 180) {
            direction = "正南";
        }
        if (angle == 270) {
            direction = "正西";
        }
        if (angle > 0 && angle < 90) {
            direction = "东北" + angle + "°";
        }
        if (angle > 90 && angle < 180) {
            direction = "东南" + angle + "°";
        }
        if (angle > 180 && angle < 270) {
            direction = "西南" + angle + "°";
        }
        if (angle > 270 && angle < 360) {
            direction = "西北" + angle + "°";
        }

        return direction;
    }
}
